package com.hzlx.productionProducts.feign.RollBack;

import com.hzlx.MesBatchesMaterialDto;
import com.hzlx.MesMaterialTransactionsDto;
import com.hzlx.productionProducts.feign.materialService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

@Component
public class materialServiceFallbackFactory implements FallbackFactory<materialService> {
    private static final Logger logger = LoggerFactory.getLogger(materialServiceFallbackFactory.class);

    @Override
    public materialService create(Throwable cause) {
        return new materialService() {
            @Override
            public AjaxResult editByOperation(@RequestBody MesBatchesMaterialDto mesBatchesMaterialDto){
                System.out.println("editByOperation失败了");
                throw new RuntimeException("物料扣减服务调用失败: " + cause.getMessage());
            }

            @Override
            public AjaxResult addByRecord(MesMaterialTransactionsDto mesMaterialTransactionsDto) {
                throw new RuntimeException("addByRecord调用失败,原因是:"+cause.getMessage());
            }

        };
    }
}
